/**
 * @author lscl
 * @version 1.0
 * @intro:
 */
public class Demo02_数组的访问 {

    public static void main(String[] args) {

        // 长度是: 4 最大下标: 3
        int[] arr = {12, 43, 5, 4, 10};

/*
        System.out.println(arr[0]);
        System.out.println(arr[1]);
        System.out.println(arr[2]);
        System.out.println(arr[3]);
        System.out.println(arr[4]);
        System.out.println(arr[5]);
*/
//        System.out.println(arr.length);

        // 数组的遍历
//        for (int i = 0; i <= arr.length-1; i++) {

        for (int i = 0; i < arr.length; i++) {

            System.out.println(arr[i]);
        }


    }

    public static void method() {
        int[] arr = new int[3];

        arr[0] = 100;
        arr[1] = 200;
        arr[2] = 99;
//        arr[3]=1000;                // 程序异常了: java.lang.ArrayIndexOutOfBoundsException: 3

        System.out.println("程序还会执行吗？？");
    }
}
